<?php
class LoginController extends Yaf_Controller_Abstract {

   	public function init(){
         if(!is_null(Yaf_Session::getInstance()->get(AK47))){
            $this->redirect('/index.php/admin/index/index');
         }
         if ($this->getRequest()->isXmlHttpRequest()) {
            Yaf_Dispatcher::getInstance()->disableView();
         }

   		$this->setViewPath(APP_PATH . '/application/modules/Admin/views');
   	}

   	public function loginAction() {
       	$this->getView()->assign("title", "惠新后台登陆");
   	}

   	public function ajax_login_checkAction(){
   		
   		$post_data = $this->getRequest()->getPost();

   		$admin_model = new adminModel();

   		$judge_res = $admin_model->admin_login_judge($post_data);
         
   		if($judge_res){
            Yaf_Session::getInstance()->set(AK47,$post_data['name']);
            exit(json_encode(array('flag'=>true,'msg'=>'登陆成功，系统跳转中...')));
         }
         exit(json_encode(array('flag'=>false,'msg'=>"<font style='color:red'>用户名或密码错误！</font>")));
   	}
}

?>
